package cate.game.play.buff.h;

import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.proce.action.ctx.SkillActionCtx;

/**
 * 友方目标每次攻击附带【源泉】目标时可恢复8%最大生命值,每回合至多生效2次
 */
public class 源泉BH extends BuffHandler {

	private double 恢复系数;

	private int 回合次数;

	//恢复系数=800&回合次数=2
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		恢复系数 = args.getWDouble("恢复系数", 0d);
		回合次数 = args.getInt("回合次数", 0);
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		roundTime = 0;
	}

	private int roundTime;

	@Override
	public void afterSufferOneAttack(SkillActionCtx action, long totalDamage, boolean strike) {
		if (roundTime >= 回合次数) {
			return;
		}
		if (buff.caster.getTeam() != action.getActor().getTeam()) {
			return;
		}
		action.getActor().attr.buffHeal(action, buff.caster, action.getActor().attr.total().hpTotal() * 恢复系数);
		roundTime++;
	}
}
